package com.yanmaohu.yulia.bean;

import java.util.List;

/**
 * @author Bright Lee
 */
public final class IdentifierChain implements ColumnReference, GeneralValueSpecification, SimpleTargetSpecification, SimpleValueSpecification, TargetArrayReference, TargetSpecification {

    private int beginIndex;
    private int endIndex;
    private List<Identifier> identifierList;

    public IdentifierChain(List<Identifier> identifierList) {
        this.beginIndex = identifierList.get(0).getBeginIndex();
        this.endIndex = identifierList.get(identifierList.size() - 1).getEndIndex();
        this.identifierList = identifierList;
    }

    @Override
    public int getBeginIndex() {
        return beginIndex;
    }

    @Override
    public int getEndIndex() {
        return endIndex;
    }

    public boolean isEmpty() {
        return identifierList == null || identifierList.isEmpty();
    }

    public int size() {
        return identifierList.size();
    }

    public Identifier get(int index) {
        return identifierList.get(index);
    }

}
